#include <iostream>
#include <vector>
#include "NavMesh.h"

using namespace std;

int main()
{
	NavMesh navMesh = NavMesh();
	float extents[3] = { 1.0f,1.0f,1.0f };
	float wideExtents[3] = { 10.0f,10.0f, 10.0f };
	bool success = navMesh.Create("srv_CAIBakedNavmesh.navmesh", 1024, extents, wideExtents);
	if (!success)
	{
		cout << "create navMesh failed" << endl;
		system("pause");
	}

	float startPoint[3];
	startPoint[0] = 40.0f;
	startPoint[1] = 0.0f;
	startPoint[2] = 40.0f;

	float endPoint[3];
	endPoint[0] = 40.0f;
	endPoint[1] = 1.0f;
	endPoint[2] = 40.0f;

	Vector3 outPaths[256] = { 0 };
	int straightPathCount = navMesh.FindStraightPath(startPoint, endPoint, outPaths);
	cout << "return " << straightPathCount << endl;

	if (straightPathCount > 0)
	{
		for (int i = 0; i < straightPathCount; ++i)
		{
			cout << outPaths[i].x << " " << outPaths[i].y << " " << outPaths[i].z << endl;
		}
	}

	//float height = 0.0;
	//navMesh.GetPolyHeight(startPoint[0], startPoint[1], startPoint[2], &height);
	//cout << height << endl;

	//float resultPoint[3];
	//if (navMesh.FindNearestPoly(startPoint[0], startPoint[1], startPoint[2], true, resultPoint))
	//{
	//	cout << "is walkable" << endl;
	//	cout << "resultPoint" << resultPoint[0] << " " << resultPoint[1] << " " << resultPoint[2] << endl;
	//}
	//else
	//{
	//	cout << "not walkable" << endl;
	//	cout << "resultPoint" << resultPoint[0] << " " << resultPoint[1] << " " << resultPoint[2] << endl;
	//}

	//if (navMesh.Raycast(startPoint[0], startPoint[1], startPoint[2], endPoint[0], endPoint[1], endPoint[2]))
	//{
	//	cout << "recast true" << endl;
	//}
	//else
	//{
	//	cout << "recast false" << endl;
	//}

	//float resultPoint[3];
	//if (navMesh.MoveAlongSurface(startPoint[0], startPoint[1], startPoint[2], endPoint[0], endPoint[1], endPoint[2], resultPoint))
	//{
	//	cout << resultPoint[0] << " " << resultPoint[1] << " " << resultPoint[2] << endl;
	//}

	system("pause");

	return 0;
}